package com.zyb.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zyb.commons.constant.Constant;
import com.zyb.commons.page.PageData;
import com.zyb.commons.page.PageResult;
import com.zyb.commons.service.impl.CrudServiceImpl;
import com.zyb.modules.log.dto.SysLogOperationDTO;
import com.zyb.modules.log.entity.SysLogOperationEntity;
import com.zyb.product.dao.BrandDao;
import com.zyb.product.dto.AttrGroupDTO;
import com.zyb.product.dto.BrandDTO;
import com.zyb.product.entity.BrandEntity;
import com.zyb.product.service.BrandService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 品牌
 *
 * @author 赵毅博 593163583@qq.com
 * @since 1.0.0 2022-07-15
 */
@Service
public class BrandServiceImpl extends CrudServiceImpl<BrandDao, BrandEntity, BrandDTO> implements BrandService {
    @Autowired
    private BrandDao brandDao;

    @Override
    public QueryWrapper<BrandEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("brandId");

        QueryWrapper<BrandEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "brand_id", id);

        return wrapper;
    }


    @Override
    public void updateBrand(BrandEntity entity) {
        brandDao.updateBrand(entity);
    }

//    @Override
//    public PageResult<BrandDTO> pageQuery(Map<String, Object> params) {
//
//        Integer pageNum = (Integer) params.get("page");
//        Integer pageSize = (Integer) params.get("limit");
//        PageResult<BrandDTO> pageResult = new PageResult<>(pageNum, pageSize);
//        int total = this.selectCount(params);
//        pageResult.setTotalCount(total);
//        List<BrandDTO> list = brandDao.queryAllLimit(params, pageResult);
//        pageResult.setResult(list);
//        return pageResult;
//    }
//
//    public int selectCount(Map<String, Object> params){
//        return brandDao.selectCounts(params);
//    }
}